package com.piotrs10.bsk.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public abstract class BaseDao {
	private final String CONNECTION_STRING = Messages.getString("BaseDao.connectionString"); //$NON-NLS-1$
	private final String USER_NAME = Messages.getString("BaseDao.login"); //$NON-NLS-1$
	private final String PASSWORD = Messages.getString("BaseDao.password"); //$NON-NLS-1$
	private final String DRIVER = Messages.getString("BaseDao.driver"); //$NON-NLS-1$

	public BaseDao() {
		try {
			Class.forName(this.DRIVER);
		} catch (ClassNotFoundException e) {
			System.err.println(e.getMessage());
		}
	}

	protected Connection getConnection() {
		Connection connection = null;
		try {
			connection = DriverManager.getConnection(this.CONNECTION_STRING,
					this.USER_NAME, this.PASSWORD);
			connection.setAutoCommit(false);
		} catch (SQLException e) {
			System.err.println(e.getMessage());
		}
		return connection;
	}

}
